using System.ComponentModel.DataAnnotations;
using GroupSix.Domain.Repositories;

namespace GroupSix.Application.Dtos;

/// <summary>
/// 操作日志DTO
/// </summary>
public class OperationLogDto
{
    /// <summary>
    /// 日志ID
    /// </summary>
    public Guid Id { get; set; }

    /// <summary>
    /// 操作人ID
    /// </summary>
    public Guid OperatorId { get; set; }

    /// <summary>
    /// 操作人用户名
    /// </summary>
    public string OperatorName { get; set; } = string.Empty;

    /// <summary>
    /// 操作类型
    /// </summary>
    public string OperationType { get; set; } = string.Empty;

    /// <summary>
    /// 操作模块
    /// </summary>
    public string Module { get; set; } = string.Empty;

    /// <summary>
    /// 操作描述
    /// </summary>
    public string Description { get; set; } = string.Empty;

    /// <summary>
    /// 操作详情
    /// </summary>
    public string Details { get; set; } = string.Empty;

    /// <summary>
    /// 操作结果
    /// </summary>
    public string Result { get; set; } = string.Empty;

    /// <summary>
    /// 错误信息
    /// </summary>
    public string ErrorMessage { get; set; } = string.Empty;

    /// <summary>
    /// IP地址
    /// </summary>
    public string IpAddress { get; set; } = string.Empty;

    /// <summary>
    /// 用户代理
    /// </summary>
    public string UserAgent { get; set; } = string.Empty;

    /// <summary>
    /// 请求URL
    /// </summary>
    public string RequestUrl { get; set; } = string.Empty;

    /// <summary>
    /// 请求方法
    /// </summary>
    public string RequestMethod { get; set; } = string.Empty;

    /// <summary>
    /// 请求参数
    /// </summary>
    public string RequestParams { get; set; } = string.Empty;

    /// <summary>
    /// 响应状态码
    /// </summary>
    public int ResponseStatusCode { get; set; }

    /// <summary>
    /// 执行时间 (毫秒)
    /// </summary>
    public long ExecutionTime { get; set; }

    /// <summary>
    /// 操作时间
    /// </summary>
    public DateTime OperationTime { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; }
}



/// <summary>
/// 创建操作日志请求DTO
/// </summary>
public class CreateOperationLogRequestDto
{
    /// <summary>
    /// 操作人ID
    /// </summary>
    [Required]
    public Guid OperatorId { get; set; }

    /// <summary>
    /// 操作人用户名
    /// </summary>
    [Required]
    [StringLength(50)]
    public string OperatorName { get; set; } = string.Empty;

    /// <summary>
    /// 操作类型
    /// </summary>
    [Required]
    [StringLength(50)]
    public string OperationType { get; set; } = string.Empty;

    /// <summary>
    /// 操作模块
    /// </summary>
    [Required]
    [StringLength(50)]
    public string Module { get; set; } = string.Empty;

    /// <summary>
    /// 操作描述
    /// </summary>
    [StringLength(500)]
    public string Description { get; set; } = string.Empty;

    /// <summary>
    /// 操作详情
    /// </summary>
    public string Details { get; set; } = string.Empty;

    /// <summary>
    /// 操作结果
    /// </summary>
    [StringLength(20)]
    public string Result { get; set; } = "success";

    /// <summary>
    /// 错误信息
    /// </summary>
    public string ErrorMessage { get; set; } = string.Empty;

    /// <summary>
    /// IP地址
    /// </summary>
    [StringLength(50)]
    public string IpAddress { get; set; } = string.Empty;

    /// <summary>
    /// 用户代理
    /// </summary>
    [StringLength(500)]
    public string UserAgent { get; set; } = string.Empty;

    /// <summary>
    /// 请求URL
    /// </summary>
    [StringLength(500)]
    public string RequestUrl { get; set; } = string.Empty;

    /// <summary>
    /// 请求方法
    /// </summary>
    [StringLength(10)]
    public string RequestMethod { get; set; } = string.Empty;

    /// <summary>
    /// 请求参数
    /// </summary>
    public string RequestParams { get; set; } = string.Empty;

    /// <summary>
    /// 响应状态码
    /// </summary>
    public int ResponseStatusCode { get; set; }

    /// <summary>
    /// 执行时间 (毫秒)
    /// </summary>
    public long ExecutionTime { get; set; }
}

/// <summary>
/// 日志导出请求DTO
/// </summary>
public class ExportLogsRequestDto
{
    /// <summary>
    /// 查询条件
    /// </summary>
    public GroupSix.Domain.Repositories.OperationLogQueryDto Query { get; set; } = new();

    /// <summary>
    /// 导出格式 (excel, csv, json)
    /// </summary>
    public string Format { get; set; } = "excel";

    /// <summary>
    /// 文件名
    /// </summary>
    public string FileName { get; set; } = "operation_logs";
} 